package dk.dashboardFP.panels.displayPanel {
	import flash.events.Event;
	import dk.dashboardFP.panels.displayPanel.core.EditorItem;
	import dk.dashboardFP.panels.displayPanel.marks.AbstractObjectMark;

	import flash.display.Sprite;

	/**
	 * @author josef
	 */
	public class SelectionMark extends AbstractObjectMark {
		
		private var _oEI : EditorItem;
		
		public function SelectionMark(oEI : EditorItem, sprContainer : Sprite) {
			_oEI = oEI;
			super(oEI.doTarget, sprContainer);
		}

		override protected function setupElements() : void {
			super.setupElements();
			
			_oEI.registerSelection(this);
			
			//:::::::
			// edit mark 
			_doAsset.alpha=0.5;
			
			//:::::::
			// updater 
			addEventListener(Event.ENTER_FRAME, onEnterFrame, false, 0, true);
			addEventListener(Event.REMOVED_FROM_STAGE, onRemovedFromStage, false, 0, true);
		}

		private function onRemovedFromStage(event : Event) : void {
			removeEventListener(Event.ENTER_FRAME, onEnterFrame);
		}

		private function onEnterFrame(event : Event) : void {
			if (_rectBounds.toString()!=_doTarget.getBounds(_sprContainer).toString()) {
				updateMark();
			}
		}
	}
}
